import os
import shutil

Root_path= 'D:\\project\\python\\datasets\\ccpd_green\\images/'
Save_path = Root_path+'changeNameTrain/'
Origin_path= Root_path+'train/'

def changeName():
    if not os.path.exists(Save_path):
        os.mkdir(Save_path)
    else:
        shutil.rmtree(Save_path)
        os.mkdir(Save_path)
    file_names=os.listdir(Origin_path)
    for file in file_names:
        names=file.split('-')
        names.pop(0)
        str_name=''
        n_index=0
        for n in names:
            if n_index==len(names)-1:
                str_name=str_name+n
            else:
                str_name=str_name+n+'-'
            n_index=n_index+1
        if names[0] == '90_267':
            shutil.copy(Origin_path+file,Save_path+str_name)
        

changeName()
